﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.ServiceModel.Syndication;


namespace Signage01
{
    [Serializable]
    public class RssReader
    {
        private string _url;
        private SyndicationFeed feed;

        public string Url
        {
            get { return _url; }
            set { _url = value; }
        }

        public RssReader(string url)
        {
            this.Url = url;
            using (XmlReader reader = XmlReader.Create(this.Url))
            {
                 feed = SyndicationFeed.Load(reader);
            }
        }

        public List<string> getNewsTitles()
        {
            //Console.WriteLine(feed.Title.Text);
            //Console.WriteLine(feed.Links[0].Uri);
            List<string> rsstitles = new List<string>();

            foreach (SyndicationItem item in feed.Items)
            {
                rsstitles.Add(item.Title.Text);            
            }

            return rsstitles;            
        }

    }
}
